package com.example.messageservice;

import android.content.Context;
import android.content.SharedPreferences;

public class SharedPreferenceUtil {
    private static volatile SharedPreferenceUtil instance = null;

    public static SharedPreferenceUtil getInstance(Context mContext) {
        if (instance == null) {
            synchronized (SharedPreferenceUtil.class) {
                if (instance == null) {
                    instance = new SharedPreferenceUtil(mContext);
                }
            }
        }
        return instance;
    }

    private SharedPreferences mSharedPreferences;

    private SharedPreferenceUtil(Context mContext) {
        mSharedPreferences = mContext.getSharedPreferences("default", Context.MODE_PRIVATE);
    }

    public long getLastSendTime() {
        return mSharedPreferences.getLong("LastSendTime", System.currentTimeMillis() - 60 * 1000);
    }

    public void setLastSendTime(long s) {
        mSharedPreferences.edit().putLong("LastSendTime", s).apply();
    }
}
